import urllib.request
import urllib.parse
url = 'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd='
# 周杰伦 utf8 = %E5%91%A8%E6%9D%B0%E4%BC%A6
name = urllib.parse.quote('周杰伦',encoding='utf-8')
url = url + name
print(url)
headers= {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0'
}
request = urllib.request.Request(url=url,headers=headers)
response = urllib.request.urlopen(request)
print(response.read().decode('utf-8'))


